let list = [
  { id: 1, title: "列表", status: 1 },
  { id: 2, title: "添加", status: 1 },
  { id: 3, title: "删除", status: 2 },
  { id: 4, title: "修改", status: 0 },
];
export default {
  'GET /api/todolists': list,
  'POST /api/addtodo': (req: any, res: any) => {
    const item = {
      id: list.length + 1,
      title: req.body.todo,
      status: 0,
    }
    list.unshift(item);
    // console.log(req);
    const mes = {
      code: 0,
      message: "添加待办事项成功"
    }
    res.send(mes)
  },
  'PUT /api/updatetodo': (req: any, res: any) => {
    const { id, status } = req.body;
    list.map((v, index) => {
      if (v && v.id === id) list[index].status = status;
    });
    // console.log(req);
    const mes = {
      code: 0,
      message: "更新成功",
      // result: list,
    }
    res.send(mes)
  }
}